<template>
	<view class="content">
		<view class="travel" :class="{ active: selectedImageIndex === index }" v-for="(item,index) in carList"
			:key="index" @click="switchStyles(index)">
			<view class="travel-image">
				<image :src="$u.fileBaseUrl+ item.carImg" mode="widthFix"></image>
			</view>
			<view class="travel-title">
				<text>{{item.name}}</text>
				<text>￥{{item.price}}</text>
			</view>
		</view>
		<view class="seemore" @click="goMoreVehicles">
			<text>查看更多车辆</text>
			<uni-icons type="right" size="20" color="#0b6ef5"></uni-icons>
		</view>
		<view class="chartered">
			<u-radio-group @change="change" v-model="value" iconPlacement="right" placement="column" size="32rpx"
				iconSize="24rpx">
				<u-radio shape="circle" name="1" labelSize="30rpx" label="我有车,不需要包车" labelColor="#0b6ef5"></u-radio>
				<u-radio shape="circle" name="2" labelSize="30rpx" label="我选择公共交通工具"></u-radio>
				<view class="chartered-bottom">
					选择公共交通工具，摄影师的交通费用由您承担!
				</view>
			</u-radio-group>
		</view>
		<view class="pace">
			<button @click="goBack()">上一步</button>
			<button @click="goNextStep()">下一步</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: 1,
				carList: [{
						image: "../../../static/images/index/1.png",
						price: "329",
						title: '宝马3系'
					},
					{
						image: "../../../static/images/index/1.png",
						price: "329",
						title: '宝马3系'
					}
				],
				selectedImageIndex: null, // 当前选中的图片索引
			};
		},
		methods: {
			change(e) {
				console.log(e);
			},
			// 跳转到查看更多页面
			goMoreVehicles() {
				uni.navigateTo({
					url: '/packagesIndex/pages/goMoreVehicles/goMoreVehicles'
				})
			},
			// 返回上一步
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			// 下一步
			goNextStep() {
				uni.navigateTo({
					url: '/packagesIndex/pages/calculation/calculation'
				})
			},
			// 切换车辆
			switchStyles(index) {
				this.selectedImageIndex = index;
			},
			// 车辆列表
			async getCarPackageList() {
				let res = await this.$u.api.getCarPackageList()
				if (res.code == 200) {
					this.carList = res.rows
				}
			},
			// 获取用户
			async getUserPlan() {
				let res = await this.$u.api.getUserPlan()
				if (res.code == 200) {

				}
			}
		},
		onLoad() {
			this.getCarPackageList()
			// this.getUserPlan()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		min-height: 95vh;
		background-color: f6f6f6;

		.travel.active {
			background: #F3F8FF;
			border: 2rpx solid #096EF4;
		}

		.travel {
			background-color: #fff;
			margin: 20rpx;
			padding: 20rpx;
			box-sizing: border-box;
			border-radius: 30rpx;

			.travel-image {
				display: flex;
				align-items: center;
				justify-content: space-between;

				image {
					flex: 1;
					margin: 15rpx;
					border-radius: 20rpx;
				}
			}

			.travel-title {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin: 0 20rpx;

				text {
					font-weight: 600;
					font-size: 32rpx;

					&:nth-child(1) {
						color: #000000;
					}

					&:nth-child(2) {
						color: #FB3D3B;
					}
				}
			}
		}

		.seemore {
			display: flex;
			align-items: center;
			justify-content: flex-end;
			color: #0b6ef5;
			margin: 30rpx;

			text {
				font-size: 28rpx;
				color: #096EF4;
				display: block;
				margin-top: -7rpx;
			}
		}

		.chartered {
			background-color: #fff;
			border-radius: 20rpx;
			margin: 20rpx;
			padding: 20rpx;

			/deep/ .u-radio {
				padding: 20rpx 0;
			}

			.chartered-bottom {
				color: #FB3D3B;
				font-size: 24rpx;
			}
		}

		.pace {
			width: 100%;
			display: flex;
			justify-content: space-around;
			align-items: center;
			background-color: f6f6f6;
			padding: 20rpx 20rpx 50rpx 20rpx;
			box-sizing: border-box;
			position: fixed;
			bottom: 0rpx;

			button {
				flex: 1;

				&:nth-child(1) {
					color: #000000;
					background-color: #fff;
					text-align: center;
					padding: 20rpx 30rpx;
					box-sizing: border-box;
					margin-right: 20rpx;
				}

				&:nth-child(2) {
					color: #ffffff;
					background-color: $overall-color;
					text-align: center;
					padding: 20rpx 30rpx;
					box-sizing: border-box;
					// margin-right: 20rpx;
				}
			}
		}

	}
</style>